package com.ruoyi.factory.receipt.controller;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.factory.common.utils.RequestUtil;
import com.ruoyi.factory.receipt.service.ReceiptService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author: LiuJiaji
 * @date: 2025/5/30 15:44
 * @description: TODO 电子收据业务 电子档案
 * @param:
 * @return:
 **/
@RestController
@RequestMapping("/api/receipt")
public class ReceiptController {


    @Autowired
    private ReceiptService receiptService;

    /**
     * @author: LiuJiaji
     * @date: 2025/5/30 16:50
     * @description: TODO 接收电子档案信息 1.接收电子档案信息 2.查询电子收据信息 3.将文件归档
     * @param:
     * @return:
     **/
    @PostMapping("/elerecordbyreceipt")
    public JSONObject elerecordbyreceipt(@RequestBody String req, HttpServletRequest request){
        Map<String, String> notifyResult = RequestUtil.getRequestParams(request);
        JSONObject jsonObject = JSONObject.fromObject(notifyResult);
        if(StringUtils.isBlank(req)){
            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.put("msg","error");
            jsonObject2.put("code","500");
            return jsonObject2;
        }
        JSONObject paramj = JSONObject.fromObject(req);
        //处理回调信息
        return receiptService.elerecordbyreceipt(paramj);
    }


}
